package 数据结构.泛型类;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        List<String> stringList = new ArrayList<>();
        stringList.add("Hello");
        stringList.add("World");

        for (String str : stringList) {
            System.out.println(str);
        }

        Map<String, Integer> map = new HashMap<>();
        map.put("One", 1);
        map.put("Two", 2);

        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }

    }
    public static void main4(String[] args) {
        ComparableBox<Integer> box = new ComparableBox<Integer>();
        box.setContent(5);
        Integer x = box.getContent();
        int rel1 = box.compareTo(4);
        int rel2 = box.compareTo(5);
        int rel3 = box.compareTo(6);
        System.out.println(rel1);
        System.out.println(rel2);
        System.out.println(rel3);
    }
    public static void main3(String[] args) {
        pair<String,Integer> pair = new OrderedPair<>("Age",30);
        String str = pair.getKey();
        Integer num = pair.getValue();
        System.out.println(str+":"+num);
    }
    public static void main2(String[] args) {
        GenericMethods ge = new GenericMethods();

        Integer[] intArray = {1,2,3,4,5};
        ge.printArray(intArray);

        String[] strArray = {"A", "B", "C", "D", "E"};
        ge.printArray(strArray);
    }
    public static void main1(String[] args) {
        //String类型
        Box<String> str = new Box<>();
        str.setContent("Hello");
        //Integer类型
        Box<Integer> num = new Box<>();
        num.setContent(13579);

        System.out.println(str.getContent());
        System.out.println(num.getContent());
    }
}
